package com.vogtec.fota.dao;

import com.vogtec.fota.dao.model.FirmWare;
import org.apache.ibatis.annotations.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by wei on 2017/7/3.
 */
public interface FirmWareDao {

    String TABLE = "firm_ware";

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert(" insert into " + TABLE + " set " +
            "firmWareName=#{firmWareName}," +
            "firmWareVersion=#{firmWareVersion}," +
            "productModel=#{productModel}," +
            "firmWareUrl=#{firmWareUrl}," +
            "firmWareDes=#{firmWareDes}," +
            "size=#{size}"
            )
    int insert(FirmWare firmWare);

    /**
     * 根据id查询固件
     * @param id
     * @return
     */
    @Select(" select * from " + TABLE + " where id=#{id}")
    FirmWare selectFWById (@Param("id") Integer id);

    /**
     * 查询所有固件
     * @return
     */
    @Select(" select * from " + TABLE)
    ArrayList<FirmWare> selectAllFW();

    List<FirmWare> select();

    /**
     * 查询所有固件个数
     * @return
     */
    @Select(" select count(*) from " + TABLE)
    int selectAllFWTotal();

    /**
     * 根据id删除固件
     * @param id
     * @return
     */
    @Delete(" delete from " + TABLE + " where id=#{id}")
    int delete(@Param("id") Integer id);
}
